/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 battlefield_window.h

	$Header: /resource_editor/battlefield_window.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( BATTLEFIELD_WINDOW_H_INCLUDED )
#define BATTLEFIELD_WINDOW_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
#include <vector>

#include "abstract_bitmap_typedef.h"
#include "battlefield_ptr.h"
#include "battlefield_preset_map_in_game.h"
#include "battlefield_window_ptr.h"
#include "combat_area_shader_ptr.h"
#include "game_window.h"
#include "idle_processor.h"
#include "owned_ptr.h"
#include "shared_ptr.h"

class	t_abstract_combat_object;
class	t_battlefield_terrain_map;
class   t_combat_object_list;
struct	t_screen_point;

// -----------------------------------------------------------------------
// t_battlefield_window class
// -----------------------------------------------------------------------
class t_battle_view_cells : public std::vector<t_combat_object_list>
{
public:
	t_screen_point const& get_size() const;
	void				  set_size( t_screen_point const& point );
	t_combat_object_list&		get( t_screen_point const& point );
	t_combat_object_list const& get( t_screen_point const& point ) const;
protected:
	t_screen_point m_size;
};

inline t_screen_point const& t_battle_view_cells::get_size() const
{
	return m_size;
}


class t_battlefield_window : public t_window
{
public:
	// Constructor/Destructor
	t_battlefield_window( t_screen_point const&				point,
						  t_window*							parent_ptr,
						  t_battlefield_ptr					battlefield_ptr,
						  t_battlefield_terrain_map const &	terrain_map,
						  t_preset_battle_map_array const&	battlefield_preset_map_vector,
						  bool								draw_terrain_background );
	virtual ~t_battlefield_window();

	// Member functions
	virtual std::string		get_help_text( t_screen_point point ) const;
	t_combat_object_list&	get_objects( t_screen_point const& point );
	virtual void			left_button_down( t_mouse_event const& event );
    virtual void			left_button_up( t_mouse_event const& event );
	virtual void			right_button_up( t_mouse_event const& event );
    virtual void			mouse_move( t_mouse_event const& event );
	virtual void			paint( t_paint_surface & paint_surface );
	void					remove_underlays();
	void					set_grid_shading( bool arg );

	// Member functions
	void			invalidate_object( t_abstract_combat_object& object );
	void            update_cursor();

protected:

	void draw_preset_background_onto( std::vector<t_battlefield_preset_map_in_game_ptr> const& battlefield_preset_map_vector,
									t_abstract_bitmap16 * memory_bitmap);

	void update_cursor( t_screen_point point );

	// Data members
	t_battlefield_ptr					m_battlefield;
	t_combat_area_shader_ptr			m_grid_shader;
	t_uint32							m_last_update_time;
	t_owned_ptr< t_abstract_bitmap16 >	m_terrain_bitmap_ptr;
	t_battle_view_cells					m_shadow_view_cells;
	t_battle_view_cells					m_view_cells;
};


#endif // !defined( BATTLEFIELD_WINDOW_H_INCLUDED )
